<script type="text/javascript" src="__PUBLIC__/plus/myfocus/myfocus-2.0.4.full.js"></script><!--引入myFocus库-->
<script type="text/javascript">
function submitForm(action) {
    $(".submit").click(function(){
        if ("" == $.trim($("#title").val())) {
            popup.error("焦点图标题不能为空");
            return false;
        }
        if ("" == $.trim($("#nid").val())) {
            popup.error("焦点图唯一标识不能为空");
            return false;
        }

        var url = ('create' == action) ? "{:U('create')}" : "{:U('update')}";


        commonAjaxSubmit(url);
        return false;
    });
}
var default_config = {
		id : 'myFocus',
		pattern : '{$focus.pattern}',
		time : '{$focus.times}' / 1,
		trigger : '{$focus.adTrigger}',
		width : '{$focus.width}' / 1,
		height : '{$focus.height}' / 1,
		txtHeight : '{$focus.txtHeight}' / 1,
		auto : '{$focus.auto}'=='1'?true:false,
		autoZoom : '{$focus.autozoom}'=='1'?true:false
	}
myFocus.set(default_config);
function apply(){
	resetHTML();
	//$("#myFocus").find("li img").css({"width" : Number(width) + "px", "height" : Number(height) + "px"});
	var config = getParam();
	myFocus.set(config);
}
var oriHtml = $('#myFocus-wrap').html();
function resetHTML() { //还原
	$('#myFocus-wrap').html(oriHtml);
	var css = document.getElementsByTagName('style')[0];
	css.parentNode.removeChild(css);
}
$(function(){
	$("#width").on("keyup", function(){
		var tmptxt=$(this).val();     
        $(this).val(tmptxt.replace(/\D|^0/g,''));  
	});
	$("#height").on("keyup", function(){
		var tmptxt=$(this).val();     
        $(this).val(tmptxt.replace(/\D|^0/g,''));  
	});
	$("#txtHeight").on("keyup", function(){
		var tmptxt=$(this).val();     
        $(this).val(tmptxt.replace(/\D|^0/g,''));  
	});
});
//获取全部参数
function getParam(){
	return {
		id : 'myFocus',
		pattern : $("#pattern").val(),
		time : $("#time").val(),
		trigger : $("#adTrigger").val(),
		width : $("#width").val()/1,
		height : $('#height').val()/1,
		txtHeight : $('#txtHeight').val()/1,
		auto : $('#auto').val()=='1'?true:false,
		autoZoom : $('#autozoom').val()=='1'?true:false
	};
}
</script>
